{extend name="base" /}

{block name="title"}抢购大厅{/block}

{block name="main"}
<div class="countgo pull-left">
	<div class="zt">
		<div class="remain">
			<div class="page-header long-header"><h3>庄园管理 <small> 抢购大厅</small></h3></div>
			<div>
				<ol class="breadcrumb">
					<li><span class="glyphicon glyphicon-home"></span><a href="/">主页</a></li>
					<li><a href="#">交易系统</a></li>
					<li class="active">抢购大厅</li>
				</ol>
			</div>

			<div class="panel panel-default">
				<div class="panel-heading">
					您的金钱余额：<span class="text-danger">{$userWallet -> money}</span>
				</div>
				<div class="panel-body">
					<table class="table table-striped table-hover">
						<tr>
					    	<th>编号</th>
					    	<th>出售用户</th>
					    	<th>果子类型</th>
					    	<th>数量</th>
					    	<th>价格</th>
					    	<th>出售时间</th>
							<th>操作</th>
						</tr>
						{volist name='fruitSells' id='fruitSell'}
							<tr>
								<td>{$fruitSell.fruit_sell_id}</td>
								<td>{$fruitSell.username}</td>
								<td>{$fruitSell.type}</td>
								<td>{$fruitSell.num}</td>
								<td>{$fruitSell.price}</td>
								<td>{$fruitSell.create_time}</td>
								<td>
									<a href="javascript:fruitBuy({$fruitSell.fruit_sell_id});" class="btn btn-danger btn-sm">购买果子</a>
								</td>
							</tr>
						{/volist}
					</table>
					<div class="text-center">
						{$fruitSells -> render()}
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
{/block}

{block name="script"}
	<script type="text/javascript">
		function fruitBuy(fruit_sell_id) {
			if(window.confirm('确认购买？')) {
				tishi2();

				$.post('/fruit/buy/handleBuy', {
					fruit_sell_id: fruit_sell_id
				}, function(result) {
					tishi2close();

					if(result['code'] != 0) {
						layer.msg(result['message']);
						return false;
					}

					window.location.reload();
				});
			}
		}
	</script>
{/block}